﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework.Constraints;
using NUnit.Framework;
using NHibernate;
using NHibernate.Cfg;
using NHibernate.Tool.hbm2ddl;
using SAKS.ViewModels;
using SAKS.Models;
using SAKS.Services;
using SAKS.IServices;

namespace SAKS.UnitTest.ServicesTest
{
    public class AchiServicesTest : TestBase
    {
        Guid Id { get; set; }
        public AchievementServices AchiServices;

        public AchiServicesTest()
        {
            AchiServices = new AchievementServices();
        }
        protected override void  CreateSomeData(ISession session)
        {         
            var achi1 = new Achievement()
            {
                Name = "ss1",
                PrimaryCompleteOrganization = "ss1",
                PrimaryCompletePerson = "ss1",
                CreatedDate = DateTime.Now
            };
            var eva = new AchiEvaluation()
            {
                EvaluateMethod = "ss"
            };
            achi1.Evaluation = eva;
            eva.Achievement = achi1;

            Id = (Guid)session.Save(achi1);
 	        base.CreateSomeData(session);
        }
        [Test]
        public void ListTest()
        {
            int? total;
            using(var session = sessionFactory.OpenSession())
            {
                AchiServices.Session = session;
                var list = AchiServices.List(0,10,out total,"");
            }
            Assert.AreEqual(1,total);
        }
        [Test]
        public void GetTest()
        {
            using (var session = sessionFactory.OpenSession())
            {
                AchiServices.Session = session;
                var achi = AchiServices.Get(Id);
                Assert.AreEqual(achi.Evaluation.EvaluateMethod, "ss");
            }
        }
    }
}
